<template>
  <div class="order-sum" v-loading="loading">
    <el-table v-show="isShow" :data="tableData" ref="order-table" border>
      <el-table-column width="250" align="center" prop="type" show-overflow-tooltip></el-table-column>
      <el-table-column
        v-for="(item, index) in tableHeader"
        :key="index"
        :label="item + ' (件)'"
        align="left"
        :prop="item"
      ></el-table-column>
      <el-table-column label="合计 (件)" align="left" prop="sum"></el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      loading: false,
      isShow: false,
      tableData: [],
      tableHeader: [],
      submitCount: {},
      finishaCount: {},
      search_params: {},

    };
  },
  methods: {
    getTableData(args) {
      this.loading = true;
      let params = {}
      params = { ...params}
      if (args) {
        params = { ...params, ...args }
      }
      this.$axios
        .get("/api/order/order_count", {
          params: params
        })
        .then(res => {
          if (res.data.code == 200) {
            this.tableData = [];
            this.tableHeader = res.data.data.month;
            let sum1 = 0,
              sum2 = 0;
            for (let i in res.data.data.submitCount) {
              sum1 += res.data.data.submitCount[i];
            }
            for (let i in res.data.data.finishaCount) {
              sum2 += res.data.data.finishaCount[i];
            }
            res.data.data.submitCount.type = "近五个月累计提交订单总数";
            res.data.data.submitCount.sum = sum1;
            this.tableData.push(res.data.data.submitCount);
            res.data.data.finishaCount.type = "近五个月累计完成订单总数";
            res.data.data.finishaCount.sum = sum2;
            this.tableData.push(res.data.data.finishaCount);
            this.loading = false;
          } else {
            this.loading = false;
            this.$message({
              type: "error",
              message: res.data.message
            });
          }
        });
    }
  }
};
</script>

<style lang='less' type='text/css'>
</style>
